package com.yh.homestay.controller;

import com.yh.homestay.pojo.CapitalGoods;
import com.yh.homestay.service.EchartsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.*;

/**
 * echarts管理
 */
@Controller
public class EchartsController {
    @Autowired
    private EchartsService echartsService;
    //查找商品操作信息（添加、删除、修改）传给前台
    @RequestMapping(value = "/echarts/items")
    @ResponseBody
    public List findItemAction(){
        Map<String,Integer> map = echartsService.echartsShowsItems();
        System.out.println(map);
        List<Map<String,Object>> list = new ArrayList<>();
        for(String in: map.keySet()){
            Map<String,Object> guan = new HashMap<>();
            guan.put("name",in);
            guan.put("value",map.get(in));
            list.add(guan);
        }
        return list;
    }


    @RequestMapping("/echarts/goods")
    @ResponseBody
    public List<CapitalGoods> capitalGoodsShow() {
        List<CapitalGoods> users = echartsService.echartsShowsGoods();
        return users;
    }

}
